package com.kingwang.training.designpattern.visitor;

import com.kingwang.training.designpattern.visitor.bo.BusinessReport;
import com.kingwang.training.designpattern.visitor.bo.CeoVisitor;
import com.kingwang.training.designpattern.visitor.bo.CtoVisitor;
import com.kingwang.training.designpattern.visitor.bo.Engineer;
import com.kingwang.training.designpattern.visitor.bo.Manager;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class VisitorApplication implements ApplicationRunner {

    public static void main(String[] args) {
        SpringApplication.run(VisitorApplication.class, args);
    }

    @Override
    public void run(ApplicationArguments args) throws Exception {
        BusinessReport report = new BusinessReport();

        report.addStaff(new Manager("经理-A"));
        report.addStaff(new Engineer("工程师-A"));
        report.addStaff(new Engineer("工程师-B"));
        report.addStaff(new Engineer("工程师-C"));
        report.addStaff(new Manager("经理-B"));
        report.addStaff(new Engineer("工程师-D"));

        System.out.println("=========== CEO看报表 ===========");
        report.showReport(new CeoVisitor());
        System.out.println("=========== CTO看报表 ===========");
        report.showReport(new CtoVisitor());
    }
}
